package com.itheima.day14_多线程.Test04;

import java.util.concurrent.ArrayBlockingQueue;

public class Worker extends Thread{
    private ArrayBlockingQueue<String> abq;

    public Worker(ArrayBlockingQueue<String> abq) {
        this.abq = abq;
    }

    @Override
    public void run() {
        while(true) {
            try {
                Thread.sleep(1000);
                abq.put("一瓶牛奶");
                System.out.println("送奶工将牛奶放入一个箱子");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
